//
//  DYPinYinTool.m
//  天气预报
//
//  Created by Dyoung on 2017/8/26.
//  Copyright © 2017年 inphase. All rights reserved.
//

#import "DYPinYinTool.h"

@implementation DYPinYinTool


+ (NSString *)getEnglishStrFromChineseStr:(NSString *)ChineseStr{
    NSDictionary * dic = @{@"多云":@"Cloudy",@"中雨":@"Rain",@"阴":@"Overcast",@"晴":@"Sun",@"大雨":@"Rain",@"小雨":@"Rain",@"阵雨":@"Rain",@"暴雨":@"Rain"};
    NSString * newStr = [dic objectForKey:ChineseStr];
    if (newStr.length == 0) {
        newStr = dic[@"多云"];
    }
    return newStr;
}

+ (NSString *)getChinesePinYinWithHZStr:(NSString *)chineseStr{
    //将NSString装换成NSMutableString
    NSMutableString *pinyin = [chineseStr mutableCopy];
    
    //将汉字转换为拼音(带音标)
    CFStringTransform((__bridge CFMutableStringRef)pinyin, NULL, kCFStringTransformMandarinLatin, NO);
//    NSLog(@"dai%@", pinyin);
    
    //去掉拼音的音标
    CFStringTransform((__bridge CFMutableStringRef)pinyin, NULL, kCFStringTransformStripCombiningMarks, NO);
//        NSLog(@"城市 %@", pinyin);
    return pinyin;
}

@end
